// 数量格式化
export function formatNumber(num) {
    if (num >= 1e4) {
        return (num / 1e4).toFixed(1) + 'w'
    } else if (num >= 1e3) {
        return (num / 1e3).toFixed(1) + 'k'
    } else {
        return num
    }
}

// 时间格式化
export function formatTime(timestamp, formatType) {
    var date = new Date(timestamp)
    var year = date.getFullYear()
    var month = date.getMonth() + 1
    var day = date.getDay()
    var hours = date.getHours()
    var minutes = date.getMinutes()
    var seconds = date.getSeconds()
    if (month < 10) month = "0" + month
    if (day < 10) day = "0" + day
    if (hours < 10) hours = "0" + hours
    if (minutes < 10) minutes = "0" + minutes
    if (seconds < 10) seconds = "0" + seconds
    if (formatType == 0) { // mm-DD
        return month + '-' + day
    }
    return year + '-' + month + '-' + day + " " + hours + ":" + minutes
}